﻿using System;
using System.Collections.Generic;
using System.Text;

namespace daSyntaxAnalyser.SyntaxTree
{
    using daBase.Objects;

    public class OuterMethodElement : SyntaxTreeElement, ISectionElementElement
    {
        private IMethodHeader header;
        private MethodBodyElement body;

        public IMethodHeader Header { get { return header; } set { header = value; } }
        public MethodBodyElement Body { get { return body; } set { body = value; } }

        public OuterMethodElement(IMethodHeader Header, MethodBodyElement Body, List<TokenInfo> Comments)
            : base(Header.StartInfo, Comments)
        {
            header = Header;
            body = Body;
        }

        public override string ToString()
        {
            return string.Format("{0}{1}", header, (body != null) ? string.Format("\r\n{0};", body) : string.Empty);
        }

        protected override IEnumerator<ISyntaxTreeElement> CreateEnumerator()
        {
            yield return header;
            if (body != null)
                yield return body;
        }
    }
}
